package com.four.hospital.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.four.common.utils.R;
import com.four.hospital.entity.Depart;
import com.four.hospital.service.DepartService;
import com.four.hospital.vo.DepartVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author:wsy
 * @Date: 2022/01/05/15:39
 * @Description
 */
@RestController
@RequestMapping("hospital/depart")
public class DepartController {

    @Autowired
    private DepartService departService;

    /**
     * 根据医院id查询科室
     *
     * @param vo
     * @param page
     * @param size
     * @param hosId
     * @return
     */
    @PostMapping("/departList/{hosId}")
    public R departList(@RequestBody DepartVo vo,
                        @RequestParam(value = "page", defaultValue = "1") Integer page,
                        @RequestParam(value = "size", defaultValue = "3") Integer size,
                        @PathVariable("hosId") Integer hosId) {
        IPage<DepartVo> departList = departService.departList(page, size, vo, hosId);
        return R.ok().put("departList", departList);
    }

    /**
     * 快速问诊
     * 输入科室名称查询科室信息
     * @param depName
     * @return
     */
    @GetMapping("/getDepartByName/{depName}")
    public R getDepartByName(@PathVariable("depName")String depName){
        Depart depart=departService.getDepartByName(depName);
        return R.ok().put("depart",depart);
    }

    /**
     * 快速问诊
     * 查询所有的科室
     * @return
     */
    @GetMapping("/getDepartAll")
    public R getDepartAll(){
        List<Depart> departList=departService.getDepartAll();
        return R.ok().put("departList",departList);
    }
}
